<template>
  <div class="hello">
    <template>
      <sjx_Header/>
    </template>
    <div class="banner">
      <p>{{ $t('header.commonProblem') }}</p>
    </div>
    <div class="body">
      <div class="body-main">
        <div class="right">
          <h3>{{ $t('faq.aboutLoan') }}</h3>
          <el-collapse 
            v-model="activeNames1">
            <template v-for="(item,index) in loanData">
              <el-collapse-item 
                :title="(index+1)+'、' + item.title" 
                :name="index+1" 
                :key="index">
                <div class="com">
                  {{ item.answer }}
                </div>
              </el-collapse-item>
            </template>
          </el-collapse>
          <h3>{{ $t('faq.aboutPay') }}</h3>
          <el-collapse 
            v-model="activeNames2">
            <el-collapse 
              v-model="activeNames2">
              <template v-for="(item,index) in backData">
                <el-collapse-item 
                  :title="(index+1)+'、' +item.title" 
                  :name="index+1" 
                  :key="index">
                  <div class="com">
                    {{ item.answer }}
                  </div>
                </el-collapse-item>
              </template>
            </el-collapse>
          </el-collapse>
        </div>
      </div>
    </div>
    <template>
      <sjx_Footer/>
    </template>
  </div>
</template>

<script>
import base from '../common/fn.js'
import sjx_Header from '../components/header'
import sjx_Footer from '../components/footer'
export default {
  name: 'Home',
  components: {
    sjx_Header,
    sjx_Footer
  },
  data() {
    return {
      bar: 1,
      activeNames1: ['1'],
      activeNames2: ['1'],
      loanData: [],
      backData: []
    }
  },
  async asyncData({ app, error }) {
    const optionHeader = {
      header: {
        ...base,
        action: 'Q0004',
        page: { index: 1, size: 100 }
      }
    }
    const option1 = { ...optionHeader, type: '1' }
    option1.appPackage = 'com.hongcheng.mydong'
    const option2 = { ...optionHeader, type: '2' }
    option2.appPackage = 'com.hongcheng.mydong'
    let [res1, res2] = await Promise.all([
      app.$axios.$post('', option1),
      app.$axios.$post('', option2)
    ])
    return {
      loanData: res1.data,
      backData: res2.data
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.body {
  width: 100%;
  min-height: 500px;
  background-color: #fff;
}
.com {
  padding: 20px;
  color: #676767;
  font-size: 16px;
  line-height: 30px;
  word-break: break-all;
}

@media screen and (min-width: 1200px) {
  .body-main {
    width: 1200px;
    height: auto;
    margin: 0 auto;
    padding: 60px 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    h3 {
      width: 100%;
      color: #3462ff;
      font-size: 24px;
      text-align: center;
      margin: 17px 0 32px;
    }
    p {
      width: 100%;
      font-size: 16px;
      color: #5c5c5c;
      text-align: center;
      line-height: 36px;
    }
  }

  .el-collapse {
    width: 800px;
  }
}
@media screen and (min-width: 768px) and (max-width: 1199px) {
  .body-main {
    width: 100%;
    height: auto;
    margin: 0 auto;
    padding: 60px 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    h3 {
      width: 100%;
      color: #3462ff;
      font-size: 24px;
      text-align: center;
      margin: 17px 0 32px;
    }
    p {
      width: 100%;
      font-size: 16px;
      color: #5c5c5c;
      text-align: center;
      line-height: 36px;
    }
  }

  .el-collapse {
    width: 800px;
  }
}
@media only screen and (max-width: 767px) {
  .body-main {
    width: 90%;
    height: auto;
    margin: 0 auto;
    padding: 30px 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    h3 {
      width: 100%;
      color: #3462ff;
      font-size: 20px;
      text-align: center;
      margin: 20px 0;
    }
    .el-collapse {
      font-size: 14px;
    }
  }
}
</style>
<style>
.el-collapse-item__header {
  height: auto;
}
@media only screen and (max-width: 479px) {
  .el-collapse-item__header {
    font-size: 12px;
    font-weight: 500;
  }
}
</style>
